package com.ailot.cloud.upms.api.listener;

import com.ailot.cloud.base.log.entity.SysLog;
import com.ailot.cloud.base.log.event.SysLogEvent;
import com.ailot.cloud.upms.api.service.SysLogService;
import lombok.AllArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 监听日志
 *
 * @author litao
 */
@Component
@AllArgsConstructor
public class SysLogListener {
    private final SysLogService sysLogService;

    @Async
    @EventListener(SysLogEvent.class)
    public void saveSysLog(SysLogEvent event) {
        SysLog sysLog = event.getSysLog();
        sysLogService.save(sysLog);
    }
}
